package com.zhao.rabbitmq.five;

import com.rabbitmq.client.Channel;
import com.zhao.rabbitmq.utils.RabbitMQUtils;

import java.util.Scanner;

/**
 * @author xiaoZhao
 * @date 2022/12/12
 * @describe 生产者 发送消息
 */
public class EmitLog {

    public static final String EXCHANGE_NAME = "logs";

    public static void main(String[] args) throws Exception{
        Channel channel = RabbitMQUtils.getChannel();
        channel.exchangeDeclare(EXCHANGE_NAME,"fanout");
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String message = scanner.next();
            channel.basicPublish(EXCHANGE_NAME,"",null,message.getBytes());
            System.out.println("生产者发送消息："+message);
        }
    }
}
